﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NHibernateClass
{
    public class AnalistasDAO
    {
        public static IList<Analistas> listAll()
        {
            IList<Analistas> analistas;
            using (NHibernate.ISession NHSession = SessionFactory.GetNewSession())
            {
                NHibernate.ICriteria query = NHSession.CreateCriteria(typeof(Analistas));
                analistas = query.List<Analistas>();
            }
            return analistas;
        }

        public static void add(Analistas analista)
        {
            using (NHibernate.ISession NHSession = SessionFactory.GetNewSession())
            {
                using (NHibernate.ITransaction trasacao = NHSession.BeginTransaction())
                {
                    NHSession.Save(analista);
                    trasacao.Commit();
                }
            }
        }

        public static void del(Analistas analista)
        {
            using (NHibernate.ISession NHSession = SessionFactory.GetNewSession())
            {
                using (NHibernate.ITransaction trasacao = NHSession.BeginTransaction())
                {
                    NHSession.Delete(analista);
                    trasacao.Commit();
                }
            }
        }
    }
}
